<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
	<title>Document</title>
	<script src="./uni.webview.1.5.2.js" type="text/javascript" charset="utf-8"></script>
	<link rel="stylesheet" href="https://a.amap.com/jsapi_demos/static/demo-center/css/demo-center.css" />
	<style>
		body,
		html {
			margin: 0px;
			padding: 0px;
			background-color: rgba(255, 255, 255, 0);
		}

		#container {
			width: 100vw;
			height: calc(100vh - 60px);
		}

		.custom-input-card {
			width: 18rem;
		}

		.custom-input-card .btn:last-child {
			margin-left: 1rem;
		}

		.content-window-card {
			position: relative;
			width: 23rem;
			padding: 0.75rem 0 0 1.25rem;
			box-shadow: none;
			bottom: 0;
			left: 0;
		}

		.content-window-card p {
			height: 2rem;
		}


		.control-btn {
			color: #FFFFFF;
			width: 28px;
			height: 28px;
			line-height: 28px;
			border-radius: 50%;
			background-color: #006b65;
			display: flex;
			justify-content: center;
			align-items: center;
			position: absolute;
		}

		.control-btn.push {
			bottom: 65px;
			right: 101px;
		}

		.control-btn.subtract {
			bottom: 65px;
			right: 58px;
		}

		.control-btn.parking {
			bottom: 65px;
			right: 15px;
		}

		.control-btn.recharge {
			bottom: 108px;
			right: 15px;
		}

		.control-btn.applycard {
			bottom: 151px;
			right: 15px;
		}

		.control-btn.pay {
			bottom: 194px;
			right: 15px;
		}

		.parklist-container {
			position: absolute;
			top: 15px;
			left: 15px;
			right: 15px;
			bottom: 15px;
			display: none;
		}

		.list-item {
			color: #666666;
			font-size: 14px;
			padding: 15px 15px;
			margin-bottom: 15px;
			border-radius: 15px;
			background-color: rgba(255, 255, 255, .7);
			box-shadow: 2px 2px 5px #333333;
		}

		.tabs-container {
			height: 40px;
			flex-shrink: 0;
			padding: 10px 0px;
			background: #FFFFFF;
			box-shadow: 0px 12px 26px 3px rgba(0, 0, 0, 0.34);
			display: flex;
		}

		.tabs-container .tab {
			width: 20vw;
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;
		}

		.tabs-container .tab img {
			width: 20px
		}

		.tabs-container .tab text {
			color: #9A9A9A;
			font-size: 12px;
		}

		.tabs-container .tab text.active {
			color: #333333;
		}
	</style>
</head>

<body>
	<div id="container"></div>
	<div class="control-btn parking" onclick="openInfo()">P</div>
	<div class="control-btn recharge" @click="showParkingList">$</div>
	<div class="control-btn applycard" @click="showParkingList">C</div>
	<div class="control-btn pay" @tap="pay">$</div>
	<div class="tabs-container">
		<div class="tab" data-tab="home">
			<img src="http://qiniu.yangpihu.net/moblie_app_slices/mine_slices/icon_home@3x.png" alt="">
			<span>首页</span>
		</div>
		<div class="tab" data-tab="parking">
			<img src="http://qiniu.yangpihu.net/moblie_app_slices/parking_imgs/icon-parking-active.png" alt="">
			<span class="active">停车</span>
		</div>
		<div class="tab" data-tab="find">
			<img src="http://qiniu.yangpihu.net/moblie_app_slices/index_slices/icon_find@3x.png" alt="">
			<span>发现</span>
		</div>
		<div class="tab" data-tab="order">
			<img src="http://qiniu.yangpihu.net/moblie_app_slices/index_slices/icon_order@3x.png" alt="">
			<span>订单</span>
		</div>
		<div class="tab" data-tab="mine">
			<img src="http://qiniu.yangpihu.net/moblie_app_slices/index_slices/icon_mine@3x.png" alt="">
			<span>我的</span>
		</div>
	</div>
	<div id="parklist-container" class="parklist-container">
	</div>
	<script type="text/javascript"
		src="https://webapi.amap.com/maps?v=1.4.15&key=b2faf570f4b2f4a39bac8896478f4d0c"></script>
	<script src="./jquery.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="./jquery.cookie.min.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript">
		function getQueryVariable(variable) {
			var query = window.location.search.substring(1);
			var vars = query.split("&");
			for (var i = 0; i < vars.length; i++) {
				var pair = vars[i].split("=");
				if (pair[0] == variable) { return pair[1]; }
			}
			return (false);
		}
		var map = new AMap.Map("container", {
			resizeEnable: true,
			center: [119.911959, 30.077152],
			zoom: 15
		});

		const token = getQueryVariable('token');

		//在指定位置打开信息窗体
		function openInfo() {
			$("#parklist-container").html("");
			$.ajax({
				url: "http://218.75.78.171:9081/api/park/all/index",
				beforeSend: (XMLHttpRequest) => {
					XMLHttpRequest.setRequestHeader("Authorization", token);
				}
			}).done((res) => {
				res.data.forEach((item) => {
					$("#parklist-container").append(`
							<div class="list-item">
							  <span style="font-weight: bold; margin-right: 5px">${item.name
						}</span>
							  <span style="font-size: 12px; margin-right: 5px">
							    <span style="font-weight: bold">总车位：</span
							    >${item.totalSet}
							  </span>
							  <span style="font-size: 12px">
							    <span style="font-weight: bold">空余车位：</span
							    >${item.nullSet}
							  </span>
							</div>
						`);
				});
			});
			$("#parklist-container").css("display", "block");
		}

		function closeInfo() {
			$("#parklist-container").css("display", "none");
		}

		$(function () {
			$(".tab").click(function () {
				if (uni) {
					uni.postMessage({
						data: {
							tabName: $(this).attr("data-tab")
						}
					});
				} else {
					window.postMessage({
						data: {
							tabName: $(this).attr("data-tab")
						}
					});
				}
			});
			$("#parklist-container").click(closeInfo);
		});
	</script>
</body>

</html>